/* glcd.h

Copyright (C) Alex S. (mailto: md5sum@alexsp.ru)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details
http://www.gnu.org/licenses/gpl-2.0.html.

You should have received a copy of the GNU General Public License
along with this program in the file gpl-2.0.txt;
if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


#ifndef GLCD_H_
#define GLCD_H_

#include "hardware.h"
#include "m41t81.h"
#include <avr/pgmspace.h>
#include "eep.h"

//#define Term_GRAPH 1

#define GLCD_PORTx PORTA
#define GLCD_DDRx DDRA
#define GLCD_PINx PINA

#define GLCD_contr PORTC
#define GLCD_contr_ddr DDRC

#define GLCD_CSA (1<<2)
#define GLCD_CSB (1<<3)
#define GLCD_RS (1<<4)
#define GLCD_RW (1<<5)
#define GLCD_E (1<<6)
#define GLCD_RST (1<<7)

#define GLCD_busy (1<<7)
#define GLCD_read() (GLCD_contr|=GLCD_RW)
#define GLCD_write() (GLCD_contr&=~GLCD_RW)

void GLCD_init();
void GLCD_xy(const uint8_t x, const uint8_t y);
void GLCD_clear();
void GLCD_print_time();
void GLCD_print_mem(const prog_uint8_t *c,const uint8_t len, const uint8_t offset, const uint8_t mask);
void GLCD_put_data(const uint8_t data);
void GLCD_print_5x8(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_3x5(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_10x16(const uint8_t c, const uint8_t offset, uint8_t space);
void GLCD_print_12x16(const uint8_t c, const uint8_t offset, uint8_t space);
void print_pressure(const uint16_t press);
void print_temp(const int8_t t,const uint8_t n, hw_ret_status err);
void print_init_progress(uint8_t percent);
//uint8_t GLCD_get_data();
void print_temp_clock(const int8_t t,const uint8_t n, const hw_ret_status err);
void print_clock();
void print_humidity(uint8_t rh, uint8_t t, uint8_t err);

void draw_date(const menu_item_t mitem);
void draw_time_adj(const menu_item_t mitem);
void draw_press_adj(const menu_item_t mitem);
void draw_exit(const menu_item_t mitem);
void draw_lcd_max(const menu_item_t mitem);
void draw_lcd_min(const menu_item_t mitem);
void draw_lcd_time(const menu_item_t mitem);

extern tm time;
#endif /* GLCD_H_ */
